package com.example.customer.service.impl;

import com.example.customer.dto.PageBean;
import com.example.customer.mapper.pageMapper;
import com.example.customer.service.pageService;
import entity.policyholders_info;
import entity.recognizee_info;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class pageServiceimpl implements pageService {
    @Autowired
    private pageMapper pageMapper;


    @Override
    public PageBean getAllPolicyholdersInfo(Integer currentPage, Integer pageSize, String name, String credentials_number) throws Exception {
        if(currentPage==null) {
            currentPage=1;
        }
        int rowCount=this.pageMapper.getRowPolicyholdersInfo(name,credentials_number);
        System.out.println(currentPage+"-----"+pageSize);
        //pageSize=5;
        //rowCount=20;
        PageBean pageBean=new PageBean(currentPage, pageSize, rowCount,name,credentials_number);

        System.out.println("开"+pageBean.getStartIndex());
        System.out.println("结"+pageBean.getEndIndex());
        List<policyholders_info> PolicyholdersInfo= this.pageMapper.getAllPolicyholdersInfo(pageBean);
        pageBean.setData(PolicyholdersInfo);
        return pageBean;
    }

    @Override
    public List<policyholders_info> getAllPolicyholdersInfos() throws Exception {
        return this.pageMapper.getAllPolicyholdersInfos();
    }

    @Override
    public PageBean getAllRecognizeeInfo(Integer currentPage, Integer pageSize, String name, String credentials_number) throws Exception {
        if(currentPage==null) {
            currentPage=1;
        }
        int rowCount=this.pageMapper.getRowRecognizeeInfo(name,credentials_number);
        System.out.println(currentPage+"-----"+pageSize);
        //pageSize=5;
        //rowCount=20;
        PageBean pageBean=new PageBean(currentPage, pageSize, rowCount,name,credentials_number);

        System.out.println("开"+pageBean.getStartIndex());
        System.out.println("结"+pageBean.getEndIndex());
        List<recognizee_info> recognizeeinfo= this.pageMapper.getAllRecognizeeInfo(pageBean);
        pageBean.setData(recognizeeinfo);
        return pageBean;
    }

    @Override
    public List<recognizee_info> getAllRecognizeeInfos() throws Exception {
        return this.pageMapper.getAllRecognizeeInfos();
    }

}
